package com.ez.supervise.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ez.supervise.core.Page;
import com.ez.supervise.dao.DemocracyGoalDao;
import com.ez.supervise.dao.base.BaseDaoImpl;
import com.ez.supervise.model.biz.DemocracyGoal;

public class DemocracyGoalDaoImpl extends BaseDaoImpl implements DemocracyGoalDao {

    public void insert(Object democracygoal) {
	sqlMapClientTemplate.insert("biz.insertDemocracyGoal", democracygoal);
    }

    public Object get(Long id) {
	return (DemocracyGoal) sqlMapClientTemplate.queryForObject("biz.getDemocracyGoalById", id);
    }

    public void update(Object org) {
	sqlMapClientTemplate.update("biz.updateDemocracyGoal", org);
    }

    public void delete(Long id) {
	sqlMapClientTemplate.update("biz.deleteDemocracyGoal", id);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.DemocracyGoalDao#findByCount(com.ez.supervise.core.Page)
     */
    public int findDemocracyGoalByCount(Page page) {
	return (Integer) getSqlMapClientTemplate().queryForObject("biz.findDemocracyGoalByCount", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.DemocracyGoalDao#findAll()
     */
    public List findAll() {
	return getSqlMapClientTemplate().queryForList("biz.findAllDemocracyGoal");
    }

    /* (non-Javadoc)
     * @see com.ez.supervise.dao.DemocracyGoalDao#findDemocracyGoalByPage(com.ez.supervise.core.Page)
     */
    public List findDemocracyGoalByPage(Page page) {
	return getSqlMapClientTemplate().queryForList("biz.findDemocracyGoalByPage", page.getConditions());
    }

    /* (non-Javadoc)
     * @see com.ez.supervise.dao.DemocracyGoalDao#findSettingByCount(com.ez.supervise.core.Page)
     */
    public int findSettingByCount(Page page) {
	return (Integer) getSqlMapClientTemplate().queryForObject("biz.findSettingByCount", page.getConditions());
    }

    /* (non-Javadoc)
     * @see com.ez.supervise.dao.DemocracyGoalDao#findSettingByPage(com.ez.supervise.core.Page)
     */
    public List findSettingByPage(Page page) {
	return getSqlMapClientTemplate().queryForList("biz.findSettingByPage", page.getConditions());
    }

    /* (non-Javadoc)
     * @see com.ez.supervise.dao.DemocracyGoalDao#findDemocracyGoal(java.lang.Integer, java.lang.String)
     */
    public List<DemocracyGoal> findDemocracyGoal(Integer year, String orgType) {
	Map map = new HashMap(2);
	map.put("year", year);
	map.put("orgType", orgType);
	return (List<DemocracyGoal>)getSqlMapClientTemplate().queryForList("biz.findDemocracyGoalByType", map);
    }

}
